package com.liu.stockmarket.ui.detail

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.liu.stockmarket.R
import com.liu.stockmarket.repository.database.entity.TransactionRecordEntity
import com.liu.stockmarket.utils.YMD
import com.liu.stockmarket.utils.getString
import java.math.BigDecimal
import java.time.LocalDate

class DetailAdapter : BaseQuickAdapter<DetailAdapter.Item, BaseViewHolder>(
    R.layout.item_stock_detail
) {


    override fun convert(holder: BaseViewHolder, item: Item) {
        holder.setText(R.id.tv_transaction_type, item.type.aliasName)
            .setText(R.id.tv_transaction_time, item.date.YMD())
            .setText(R.id.tv_transaction_money, "总金额：${item.money.getString()}")
            .setText(R.id.tv_transaction_handling_fee, "手续费:${item.handlingFee.getString()}")
            .setText(R.id.tv_transaction_price, "单价：${item.transactionPrice.getString(4)}")
            .setText(R.id.tv_transaction_number, "数量：${item.transactionNumber.getString()}")

    }

    data class Item(
        val type: TransactionRecordEntity.TransactionType,
        val date: LocalDate,
        val money: BigDecimal,
        val handlingFee: BigDecimal,
        val transactionPrice: BigDecimal,
        val transactionNumber: BigDecimal,
    )
}